import { getCompanyID, getPosIDs, getUserDepID, getUserID, requestFunComponFiex } from '@/utils';
import { useRequest } from 'umi';
import { getBaseUrl } from '@/services/urlconst';

const baseUrl = getBaseUrl();

const PublishServices = (callback: (res: any) => void) => {
  const { loading, run } = useRequest(
    (reqParams: any) => {
      let PostParams = {
        ...reqParams,
        publishID: getUserID(),
        publishPositionID: getPosIDs(),
        publishDepartmentID: getUserDepID(),
        publishCompanyID: getCompanyID(),
      };

      const reqbody: Record<string, any> = PostParams;

      const reqUrl = `${baseUrl}/purchaseSourceIntentController/intentPublishTime`;

      delete reqbody.key;
      /***发起请求数据接口**/
      return requestFunComponFiex('POST', reqUrl, reqbody);
    },
    {
      manual: true,
      onSuccess: callback,
    },
  );
  return {
    loading,
    publishRequest: run,
  };
};
export { PublishServices };
